package hr.infomare.drrh.pojo;

// Generated 21.09.2011. 15:44:13 by Hibernate Tools 3.2.1.GA

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.StringUtils;

import budgetuserlibrary.gw.fmis.ibm.hr.infotypes.BudgetCommitmentStatusType;
import budgetuserlibrary.gw.fmis.ibm.hr.infotypes.NotificationHeader;

/**
 * Budcom generated by hbm2java
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "BUDCOM")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
public class Budcom implements java.io.Serializable {

	private String curlib;
	private String r95upr;
	private int r95god;
	private int r95rbr;

	private int notheadid;
	private long resmsgid;
	private int bcstatid;
	private int bufmisdoc;
	private String fmisgwnid;
	private String orsapdocid;
	private String orbufmisid;
	private String bcstattype;
	private Date datetimews;

	public Budcom() {
	}

	@Id
	@Column(name = "CURLIB", nullable = false, length = 10)
	public String getCurlib() {
		return this.curlib;
	}

	public void setCurlib(String curlib) {
		this.curlib = curlib;
	}

	@Id
	@Column(name = "R95UPR", nullable = false, length = 4)
	public String getR95upr() {
		return this.r95upr;
	}

	public void setR95upr(String r95upr) {
		this.r95upr = r95upr;
	}

	@Id
	@Column(name = "R95GOD", nullable = false, precision = 4, scale = 0)
	public int getR95god() {
		return this.r95god;
	}

	public void setR95god(int r95god) {
		this.r95god = r95god;
	}

	@Id
	@Column(name = "R95RBR", nullable = false, precision = 7, scale = 0)
	public int getR95rbr() {
		return this.r95rbr;
	}

	public void setR95rbr(int r95rbr) {
		this.r95rbr = r95rbr;
	}

	@Column(name = "NOTHEADID", nullable = false, precision = 9, scale = 0)
	public int getNotheadid() {
		return this.notheadid;
	}

	public void setNotheadid(int notheadid) {
		this.notheadid = notheadid;
	}

	@Column(name = "RESMSGID", nullable = false, precision = 9, scale = 0)
	public long getResmsgid() {
		return this.resmsgid;
	}

	public void setResmsgid(long resmsgid) {
		this.resmsgid = resmsgid;
	}

	@Column(name = "BCSTATID", nullable = false, precision = 9, scale = 0)
	public int getBcstatid() {
		return this.bcstatid;
	}

	public void setBcstatid(int bcstatid) {
		this.bcstatid = bcstatid;
	}

	@Column(name = "BUFMISDOC", nullable = false, precision = 9, scale = 0)
	public int getBufmisdoc() {
		return this.bufmisdoc;
	}

	public void setBufmisdoc(int bufmisdoc) {
		this.bufmisdoc = bufmisdoc;
	}

	@Column(name = "FMISGWNID", nullable = true, length = 50)
	public String getFmisgwnid() {
		return this.fmisgwnid;
	}

	public void setFmisgwnid(String fmisgwnid) {
		this.fmisgwnid = fmisgwnid;
	}

	@Column(name = "ORSAPDOCID", nullable = false, length = 50)
	public String getOrsapdocid() {
		return this.orsapdocid;
	}

	public void setOrsapdocid(String orsapdocid) {
		this.orsapdocid = orsapdocid;
	}

	@Column(name = "ORBUFMISID", length = 50)
	public String getOrbufmisid() {
		return this.orbufmisid;
	}

	public void setOrbufmisid(String orbufmisid) {
		this.orbufmisid = orbufmisid;
	}

	@Column(name = "BCSTATTYPE", nullable = false, length = 50)
	public String getBcstattype() {
		return this.bcstattype;
	}

	public void setBcstattype(String bcstattype) {
		this.bcstattype = bcstattype;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "DATETIMEWS", nullable = false, length = 10)
	public Date getDatetimews() {
		return this.datetimews;
	}

	public void setDatetimews(Date datetimews) {
		this.datetimews = datetimews;
	}

	public void postaviVrijednosti(Budcommsg budComMsg, Integer notHeadId,
			Integer statNotId, NotificationHeader notificationHeader,
			BudgetCommitmentStatusType budgetCommitmentStatusType, Resmsg resMsg) {
		if (this.curlib == null) {
			curlib = budComMsg.getCurlib();
			r95upr = budComMsg.getR95upr();
			r95god = budComMsg.getR95god();
			r95rbr = budComMsg.getR95rbr();
		}
		notheadid = notHeadId;
		resmsgid = resMsg.getResmsgid();
		bcstatid = statNotId;
		bufmisdoc = budComMsg.getBcmsgid();
		fmisgwnid = StringUtils.isBlank(notificationHeader
				.getFmisGwNotificationId()) ? " " : notificationHeader
				.getFmisGwNotificationId();
		orsapdocid = StringUtils.defaultString(StringUtils
				.isBlank(notificationHeader.getSapDocumentId()) ? orsapdocid
				: notificationHeader.getSapDocumentId());
		orbufmisid = StringUtils
				.defaultString(StringUtils.isBlank(notificationHeader
						.getOriginatingBuFmisDocumentID()) ? orbufmisid
						: notificationHeader.getOriginatingBuFmisDocumentID());
		bcstattype = budgetCommitmentStatusType != null ? budgetCommitmentStatusType
				.name() : " ";
		datetimews = resMsg.getSubmdati();
	}
}
